#!/bin/bash

#=======================================================================
# ngttest
# File ID: b08ec95a-f743-11dd-a59e-000475e441b9
# Sjekker om den NextGenTel-forbindelsen er herpa
# License: GNU General Public License version 2 or later.
#=======================================================================

logdir=~/log/ngt
[ -d $logdir/. ] || mkdir -p $logdir || { echo $logdir: Gikk på trynet å lage den. >&2; exit 1; }

res=`sget http://nett.ba.no/ngt/test | tohex | rmspcall`

logfile=$logdir/logg.txt
echo -n `u -L` "Fikk \"$res\". " >>$logfile
if [ "$res" = "0a 00 00 02" ]; then
    echo OK >>$logfile
    tail -1 $logfile
    exit 0
else
    echo HERPA >>$logfile
    tail -1 $logfile
    exit 1
fi
